package vip.xiaonuo.modular.manage.biUserIndexSpu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import vip.xiaonuo.modular.manage.biUserIndexSpu.entity.BiUserIndexSpu;
import vip.xiaonuo.modular.manage.biUserIndexSpu.mapper.BiUserIndexSpuMapper;
import vip.xiaonuo.modular.manage.biUserIndexSpu.service.BiUserIndexSpuService;
import org.springframework.stereotype.Service;

/**
 * 用户指标的样式属性(BiUserIndexSpu)表服务实现类
 *
 * @author makejava
 * @since 2022-08-08 16:07:46
 */
@Service("biUserIndexSpuService")
public class BiUserIndexSpuServiceImpl extends ServiceImpl<BiUserIndexSpuMapper, BiUserIndexSpu> implements BiUserIndexSpuService {


    @Override
    public BiUserIndexSpu findByUserIdAndIndexId(Long userId, Long indexTypeId) {
        LambdaQueryWrapper<BiUserIndexSpu> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BiUserIndexSpu::getUserId,userId);
        wrapper.eq(BiUserIndexSpu::getIndexTypeId,indexTypeId);
        return getBaseMapper().selectOne(wrapper);
    }

    @Override
    public void removeByUserIdAndIndexId(Long userId, Long indexTypeId) {
        LambdaUpdateWrapper<BiUserIndexSpu> wrapper = new LambdaUpdateWrapper();
        wrapper.eq(BiUserIndexSpu::getUserId,userId);
        wrapper.eq(BiUserIndexSpu::getIndexTypeId,indexTypeId);
        this.remove(wrapper);
    }
}

